import { http } from '@/utils/http/axios';

const baseUrl = `/api`;

export interface BasicResponseModel<T = any> {
  code: number;
  message: string;
  result: T;
}

/**
 * @description: 用户登录
 */
export function login(params) {
  return http.request<BasicResponseModel>(
    {
      url: `${baseUrl}/v1/sms/auth/login`,
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    },
  );
}

/**
 * @description: 获取用户信息
 */
export function getUserInfo() {
  return http.request({
    url: `${baseUrl}/v1/sms/v1/auth/user`,
    method: 'get',
  });
}

/**
 * @description: 获取用户按钮权限
 */
export function getUseButtonPermission(params) {
  return http.request(
    {
      url: `${baseUrl}/v1/sms/v1/auth/buttons`,
      method: 'get',
      params,
    },
    {
      isTransformResponse: false,
    },
  );
}

/**
 * @description: 获取该用户的菜单
 */
export function adminMenus(params) {
  return http.request(
    {
      url: `${baseUrl}/v1/sms/v1/auth/menus`,
      method: 'get',
      params,
    },
    {
      isTransformResponse: false,
    },
  );
}

/**
 * @description: 重新签发子系统token
 */
export function restToken(params) {
  return http.request(
    {
      url: `${baseUrl}/v1/sms/v1/auth/resign`,
      method: 'get',
      params,
    },
    {
      isTransformResponse: false,
    },
  );
}

/**
 * @description: 用户修改密码
 */
export function changePsd(params) {
  return http.request(
    {
      url: `${baseUrl}/v1/sms/v1/user/change-password`,
      method: 'PUT',
      params,
    },
    {
      isTransformResponse: false,
    },
  );
}

/**
 * @description: 获取验证码信息
 */
export function getCaptcha() {
  return http.request({
    url: `${baseUrl}v1/sms/v1/auth/captcha`,
    method: 'get',
  });
}
